package com.king.first.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.king.first.bean.Order;

import java.lang.reflect.Field;

public class JSONUtils<T> {


    public static void main(String[] args) throws ClassNotFoundException {
        String json = "{\"database\":\"yidian_ceshi\",\"table\":\"tb_nc_member_order_info\",\"type\":\"insert\",\"ts\":1631070469,\"xid\":178047739,\"commit\":true,\"position\":\"mysql-bin.000339:14796697\",\"data\":{\"moi_id\":5853323,\"member_id\":215267}}";
        JSONObject r = JSON.parseObject(json);
        String data = r.getString("data");
        JSONObject beanJson = JSON.parseObject(data);
        Field[] declaredFields = Class.forName(Order.class.getTypeName()).getDeclaredFields();
        for (Field field : declaredFields) {
            System.out.println(field.getName());
        }

    }

    public T jsonToBean(T t, String data){
        JSONObject r = JSON.parseObject(data);



        return null;
    }
}
